<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;

class LikeCollection extends BaseCollection
{
    public function toArray(Request $request): array
    {
        return [
            'data' => $this->collection->map(function ($item) {
                return [
                    'nickname' => $item->user->nickname,
                    'avatar' => $item->user->avatar,
                    'polls' => $item->polls,
                    'created' => (string) $item->created_at,
                ];
            }),
            'page' => $this->page(),
        ];
    }
}
